package cc.wsyw126.java.nowcoder.sword_offer;

/**
 * Created by dp on 17/3/28.
 */
public class Print1_N {
    public void print1_N(int n) {
        if (n < 0) return;
        char[] number = new char[n];
        for (int i = 0; i < 10; i++) {
            number[0] = (char) (i + '0');
            doPrint1_N(number, n, 0);
        }
    }

    private void doPrint1_N(char[] number, int n, int index) {
        if (n - 1 == index) {
            for (int i = 0; i < n; i++) {
                System.out.print(number[i]);
            }
            System.out.println();
            return;
        }
        for (int i = 0; i < 10; i++) {
            number[index + 1] = (char) (i + '0');
            doPrint1_N(number, n, index + 1);
        }
    }

    public static void main(String[] args) {
        Print1_N print1_n = new Print1_N();
        print1_n.print1_N(3);
    }
}
